/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFUserVMEUnpacker
  \brief User class to implement the user-specific part of the vme decoding
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-09-27
  \date 2021-10-03 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-09-27   <td>Asia Sun    <td>file created                  </tr>
  <tr>  <td>2021-10-03   <td>Asia Sun    <td>completing                    </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFUserVMEUnpacker_h
#define ETFUserVMEUnpacker_h

#include "ETFVMEUnpacker.h"

class ETFVMERawEvent;

class ETFUserVMEUnpacker : public ETFVMEUnpacker{
public:
  ETFUserVMEUnpacker(); ///< type=0 is used to indicate VME daq
  virtual ~ETFUserVMEUnpacker();

  virtual void Register(); ///< add fRawEvent into root tree
  virtual void Reset(); ///< reset for next event
  void SetUserDebug(bool opt){ fDebug = opt; }

  const ETFVMERawEvent *GetRawEvent(){ return fRawEvent; }

  ClassDef(ETFUserVMEUnpacker, 0); // user-specific part unpacker for VME raw data

protected:
  /// customizable user event-decoding for a certain vme-config
  /// user to implement this method should be aware that the data to be decoded
  /// starts from fData[fPos+3] to fData[fPos+fEvent.fEventHead.event_length]
  virtual void UserDecode();

  ETFVMERawEvent *fRawEvent;
  bool fDebug;
};

#endif
